﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Lab1.AnswerSpace
{
    /// <summary>
    /// Interaction logic for Index.xaml
    /// </summary>
    public partial class Index : Page
    {
        AnswerService aService = new AnswerService();
        public Index()
        {
            InitializeComponent();
            var all = aService.getAll();
            answerListBox.DataContext = all;    
        }

        private void Create(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Create());
        }

        private void Delete(object sender, RoutedEventArgs e)
        {
            AnswerVariant answer = (AnswerVariant)answerListBox.SelectedItem;
            this.NavigationService.Navigate(new Delete(answer));
        }

        private void Edit(object sender, RoutedEventArgs e)
        {
            AnswerVariant answer = (AnswerVariant)answerListBox.SelectedItem;
            this.NavigationService.Navigate(new Edit(answer));
        }
    }
}
